package io.noties.markwon.plugin.typogram.bean


/**
 * @author Efstathios Sideris
 */
class ProcessingOptions {
    private var customShapes = HashMap<String, CustomShapeDefinition>()
    private var beVerbose = false
    private var printDebugOutput = false
    private var overwriteFiles = false
    private var performSeparationOfCommonEdges = true
    private var allCornersAreRound = false
    /**
     * @return
     */
    /**
     * @param i
     */
    var tagProcessingMode = USE_TAGS
    /**
     * @return
     */
    /**
     * @param i
     */
    var colorCodesProcessingMode = USE_COLOR_CODES
    /**
     * @return
     */
    /**
     * @param i
     */
    var exportFormat = FORMAT_PNG
    /**
     * @return
     */
    /**
     * @param i
     */
    var tabSize = DEFAULT_TAB_SIZE
    /**
     * @return
     */
    /**
     * @param string
     */
    var inputFilename: String? = null
    /**
     * @return
     */
    /**
     * @param string
     */
    var outputFilename: String? = null
    var characterEncoding: String? = null

    /**
     * @return
     */
    fun areAllCornersRound(): Boolean {
        return allCornersAreRound
    }

    /**
     * @return
     */
    fun performSeparationOfCommonEdges(): Boolean {
        return performSeparationOfCommonEdges
    }

    /**
     * @param b
     */
    fun setAllCornersAreRound(b: Boolean) {
        allCornersAreRound = b
    }

    /**
     * @param b
     */
    fun setPerformSeparationOfCommonEdges(b: Boolean) {
        performSeparationOfCommonEdges = b
    }

    /**
     * @return
     */
    fun verbose(): Boolean {
        return beVerbose
    }

    /**
     * @return
     */
    fun printDebugOutput(): Boolean {
        return printDebugOutput
    }

    /**
     * @param b
     */
    fun setVerbose(b: Boolean) {
        beVerbose = b
    }

    /**
     * @param b
     */
    fun setPrintDebugOutput(b: Boolean) {
        printDebugOutput = b
    }

    /**
     * @return
     */
    fun overwriteFiles(): Boolean {
        return overwriteFiles
    }

    /**
     * @param b
     */
    fun setOverwriteFiles(b: Boolean) {
        overwriteFiles = b
    }

    fun getCustomShapes(): HashMap<String, CustomShapeDefinition> {
        return customShapes
    }

    fun setCustomShapes(customShapes: HashMap<String, CustomShapeDefinition>) {
        this.customShapes = customShapes
    }

    fun putAllInCustomShapes(customShapes: HashMap<String, CustomShapeDefinition>?) {
        this.customShapes.putAll(customShapes!!)
    }

    fun getFromCustomShapes(tagName: String): CustomShapeDefinition? {
        return customShapes[tagName]
    }

    companion object {
        const val USE_TAGS = 0
        const val RENDER_TAGS = 1
        const val IGNORE_TAGS = 2
        const val USE_COLOR_CODES = 0
        const val RENDER_COLOR_CODES = 1
        const val IGNORE_COLOR_CODES = 2
        const val FORMAT_JPEG = 0
        const val FORMAT_PNG = 1
        const val FORMAT_GIF = 2
        const val DEFAULT_TAB_SIZE = 8
    }
}


class CustomShapeDefinition {
    var tag: String? = null
    private var stretch = false
    private var dropShadow = true
    private var hasBorder = false
    var filename: String? = null
    var comment: String? = null

    fun dropsShadow(): Boolean {
        return dropShadow
    }

    fun setDropsShadow(dropShadow: Boolean) {
        this.dropShadow = dropShadow
    }

    fun stretches(): Boolean {
        return stretch
    }

    fun setStretches(stretch: Boolean) {
        this.stretch = stretch
    }

    fun hasBorder(): Boolean {
        return hasBorder
    }

    fun setHasBorder(hasBorder: Boolean) {
        this.hasBorder = hasBorder
    }

    override fun toString(): String {
        return """Custom shape: "${tag}":
	file: ${filename}
	stretches: ${stretches()}
	has border: ${hasBorder()}
	drops shadow: ${dropsShadow()}
	comment: ${comment}
"""
    }
}
